const app = getApp();
Component({
  options: {
    addGlobalClass: true,
  },
  data: {
    CustomBar: app.globalData.CustomBar,
    swiperList: [{
      id: 0,
      type: 'image',
      url: '../../../images/t1.jpg'
    }, {
      id: 1,
      type: 'image',
      url: '../../../images/t2.jpg',
    }, {
      id: 2,
      type: 'image',
      url: '../../../images/t3.jpg'
    }],
    allList: null
  },
  attached() {
    var that = this;
    wx.request({
      url: app.globalData.local_url + 'api/gameList',
      data: {
        sort: '商品'
      },
      method: 'GET',
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        if (res.data.code == 200) {
          that.setData({
            allList: res.data.data,
          });
        } else {
          console.error("Failed to fetch data");
        }
      }
    })
  },
  methods: {
    getData(e) {
      wx.navigateTo({
        url: '/pages/activity/search/search?type=1'
      })
    },
    goInfo(e) {
      var id = e.currentTarget.dataset.id;
      wx.navigateTo({
        url: '/pages/activity/info/info?id=' + id
      })
    }
  }
})
